import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus';
import 'element-plus/lib/theme-chalk/index.css';
// 导入全局样式表
import './assets/css/global.css'
// 导入字体图标
import './assets/font/iconfont.css'
import'./assets/font_2426752_bvohz0x4fvm/iconfont.css'
// 导入axios
import Axios from './axios/index.js'

// 挂载路由全局导航守卫,
router.beforeEach((to, from, next) => {
  if(to.path == '/login'){
    return next()
  }
  // 获取token
  const token = sessionStorage.getItem('token')
  if(!token){
    return next('/login')
  } else {
    next()
  }
})

// createApp(App).use(router).mount('#app')
const app = createApp(App)
app.config.globalProperties.$axios = Axios
app.use(ElementPlus)
app.use(router)
app.mount('#app')
